/*
 * gplayer.cc
 *
 *  Created on: Sep 25, 2012
 *      Author: shaohong
 */

#include "gplayer.hh"
#include <iostream>

using namespace std;

size_t GolfPlayer::idCounter = 0;

GolfPlayer::GolfPlayer(const std::string& name, Gender gender, double handicap):
		name(name), gender(gender), handicap(handicap) {
	this->id = GolfPlayer::idCounter++;

}

const std::string& GolfPlayer::getName() const {
	return this->name;
}

Gender GolfPlayer::getGender() const {
	return this->gender;
}

double GolfPlayer::getHandicap() const {
	return this->handicap;
}

void GolfPlayer::setHandicap(double newHandicap) {
	this->handicap = newHandicap;
}

size_t GolfPlayer::getId() const {
	return this->id;
}

static std::string genderStr(Gender gender) {
	switch (gender) {
	case MALE:
		return "male";
	case FEMALE:
		return "female";
	};

	return "";
}

std::ostream& operator<<(std::ostream& out, const GolfPlayer& player) {
//    * Player information:
//    * Id: 0
//    * Name: Petteri Koivumaki
//    * Gender: male
//    * Handicap: 7.5
	out << "Player information:" << endl;
	out << "Id: " << player.getId() << endl;
	out << "Name: " << player.getName() << endl;
	out << "Gender: " << genderStr(player.getGender())<< endl;
	out << "Handicap: " << player.getHandicap();

	return out;
}

